/**********************************************
*  Classes:   Light
*  Desc:      Defines an light in the scene. 
*  Author:    Vaios Kalpias-Ilias (C) 2008-2009
***********************************************/

#ifndef LIGHT_H
#define LIGHT_H

#include "SmartPointer.h"
#include "Vector.h"

class Light
{
public:

	enum LightType
	{
		LIGHT_AMBIENT,
		LIGHT_DIRECTIONAL,
		LIGHT_SPOT,
		LIGHT_POINT
	};
	
	Light(LightType type);
	~Light();

	void SetPosition(const mth::Vector3& pos)
	{
		m_vPos = pos;
	}

	void SetDirection(const mth::Vector3& dir)
	{
		if (m_eType == LIGHT_DIRECTIONAL ||
			m_eType == LIGHT_SPOT)
		{
			m_vDirection = dir;
		}
	}

	void SetAmbient(const mth::Vector3& ambient)
	{
		m_vAmbient = ambient;
	}
	
	void SetDiffuse(const mth::Vector3& diffuse)
	{
		m_vDiffuse = diffuse;
	}

	void SetSpecular(const mth::Vector3& specular)
	{
		m_vSpecular = specular;
	}

	const mth::Vector3& GetPosition() const
	{
		return m_vPos;
	}

	const mth::Vector3& GetDirection() const
	{
		return m_vDirection;
	}

	const LightType GetType() const
	{
		return m_eType;
	}

	const mth::Vector3& GetAmbient() const
	{
		return m_vAmbient;
	}

	const mth::Vector3& GetDiffuse() const
	{
		return m_vDiffuse;
	}

	const mth::Vector3& GetSpecular() const
	{
		return m_vSpecular;
	}

	void TurnOn()
	{
		m_bOn = true;
	}

	void TurnOff()
	{
		m_bOn = false;
	}

	bool IsOn() const
	{
		return m_bOn;
	}

	unsigned int GetId() const
	{
		return m_uiId;
	}

	// Gets distance from a certain position
	float GetDistanceFrom(const mth::Vector3& pos) const;
private:

	// light type
	LightType m_eType;
	// light pos
	mth::Vector3 m_vPos;
	// light direction
	mth::Vector3 m_vDirection;
	// light color
	mth::Vector3 m_vAmbient;
	mth::Vector3 m_vDiffuse;
	mth::Vector3 m_vSpecular;
	// is the light on
	bool m_bOn;
	// light id
	static unsigned int m_uiGlobalId;
	unsigned int m_uiId;

};

SmartPointer(Light);

#endif